<?php


namespace app\api\model\order;


use app\logic\model\OrderPayModel as OrderPay;

class OrderPayModel extends OrderPay
{
    function getList($param,$field='*',$limit=15,$order='id desc'){
        global $user;
        $list=$this->where(function($q) use ($param,$user){
            if(check_request($param,'type')){
                if($param['type']==1){//买入 buyer_uid=当前用户
                    $q->where('buyer_id',$user['id']);
                }else{//卖出 seller_id=当前用户
                    $q->where('seller_id',$user['id']);
                }
                if(check_request($param,'status')){
                    $q->where('status',$param['status']);
                }
            }
        })->where('type',1)->field($field)->order($order)->paginate($limit);
        if(!$list->isEmpty()){
            return $list->toArray();
        }
        return $list;
    }
}